From 9ac1d196c952de8846528b57ed046ac040750d8b Mon Sep 17 00:00:00 2001 From: "Karl O. Pinc kop@karlpinc.com" Date: Mon, 20 Jul 2026 21:15:49 +0000 Subject: [PATCH] Create, document, index, and trigger FOOD_VARIATIONS --- db/schemas/housekeeping/indexes/Makefile | 1 + .../indexes/create/food_variations.m4 | 26 +++++++ .../indexes/drop/food_variations.m4 | 24 ++++++ db/schemas/housekeeping/tables/Makefile | 1 + .../tables/create/food_variations.m4 | 36 +++++++++ db/schemas/lib/triggers/Makefile | 3 +- .../lib/triggers/create/food_variations.m4 | 49 +++++++++++++ .../lib/triggers/drop/food_variations.m4 | 23 ++++++ doc/src/epilog.inc.m4 | 8 ++ doc/src/housekeeping.m4 | 1 + doc/src/housekeeping/food_variations.m4 | 73 +++++++++++++++++++ 11 files changed, 244 insertions(+), 1 deletion(-) create mode 100644 db/schemas/housekeeping/indexes/create/food_variations.m4 create mode 100644 db/schemas/housekeeping/indexes/drop/food_variations.m4 create mode 100644 db/schemas/housekeeping/tables/create/food_variations.m4 create mode 100644 db/schemas/lib/triggers/create/food_variations.m4 create mode 100644 db/schemas/lib/triggers/drop/food_variations.m4 create mode 100644 doc/src/housekeeping/food_variations.m4 diff --git a/db/schemas/housekeeping/indexes/Makefile b/db/schemas/housekeeping/indexes/Makefile index 7fbbb8f..3bb4c39 100644 --- a/db/schemas/housekeeping/indexes/Makefile +++ b/db/schemas/housekeeping/indexes/Makefile @@ -23,6 +23,7 @@ ORDER := aggression_event_log \ biography_log \ chimps_on_tikis \ community_membership_update_log \ + food_variations \ tlk_brecord_notes_codes ## diff --git a/db/schemas/housekeeping/indexes/create/food_variations.m4 b/db/schemas/housekeeping/indexes/create/food_variations.m4 new file mode 100644 index 0000000..55db40c --- /dev/null +++ b/db/schemas/housekeeping/indexes/create/food_variations.m4 @@ -0,0 +1,26 @@ +dnl Copyright (C) 2026 The Meme Factory, Inc., http://www.karlpinc.com/ +dnl +dnl This program is free software: you can redistribute it and/or modify +dnl it under the terms of the GNU Affero General Public License as published +dnl by the Free Software Foundation, either version 3 of the License, or +dnl (at your option) any later version. +dnl +dnl This program is distributed in the hope that it will be useful, +dnl but WITHOUT ANY WARRANTY; without even the implied warranty of +dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +dnl GNU Affero General Public License for more details. +dnl +dnl You should have received a copy of the GNU Affero General Public License +dnl along with this program. If not, see . +dnl +dnl Karl O. Pinc +dnl +dnl +dnl m4 includes +include(`copyright.m4')dnl +include(`constants.m4')dnl +include(`indexmacros.m4')dnl + +CREATE UNIQUE INDEX IF NOT EXISTS food_variations_abbreviation + ON food_variations + (sdb_case_equivalence(`variant')); diff --git a/db/schemas/housekeeping/indexes/drop/food_variations.m4 b/db/schemas/housekeeping/indexes/drop/food_variations.m4 new file mode 100644 index 0000000..f0ef192 --- /dev/null +++ b/db/schemas/housekeeping/indexes/drop/food_variations.m4 @@ -0,0 +1,24 @@ +dnl Copyright (C) 2026 The Meme Factory, Inc., http://www.karlpinc.com/ +dnl +dnl This program is free software: you can redistribute it and/or modify +dnl it under the terms of the GNU Affero General Public License as published +dnl by the Free Software Foundation, either version 3 of the License, or +dnl (at your option) any later version. +dnl +dnl This program is distributed in the hope that it will be useful, +dnl but WITHOUT ANY WARRANTY; without even the implied warranty of +dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +dnl GNU Affero General Public License for more details. +dnl +dnl You should have received a copy of the GNU Affero General Public License +dnl along with this program. If not, see . +dnl +dnl Karl O. Pinc +dnl +dnl +dnl m4 includes +include(`copyright.m4')dnl +include(`constants.m4')dnl +include(`indexmacros.m4')dnl + +DROP INDEX IF EXISTS food_variations_abbreviation; diff --git a/db/schemas/housekeeping/tables/Makefile b/db/schemas/housekeeping/tables/Makefile index f15e8eb..6336b18 100644 --- a/db/schemas/housekeeping/tables/Makefile +++ b/db/schemas/housekeeping/tables/Makefile @@ -24,6 +24,7 @@ ORDER := aggression_event_log \ biography_log \ chimps_on_tikis \ community_membership_update_log \ + food_variations \ tlk_brecord_notes_codes ## diff --git a/db/schemas/housekeeping/tables/create/food_variations.m4 b/db/schemas/housekeeping/tables/create/food_variations.m4 new file mode 100644 index 0000000..6f74cfc --- /dev/null +++ b/db/schemas/housekeeping/tables/create/food_variations.m4 @@ -0,0 +1,36 @@ +dnl Copyright (C) 2026 The Meme Factory, Inc., http://www.karlpinc.com/ +dnl +dnl This program is free software: you can redistribute it and/or modify +dnl it under the terms of the GNU Affero General Public License as published +dnl by the Free Software Foundation, either version 3 of the License, or +dnl (at your option) any later version. +dnl +dnl This program is distributed in the hope that it will be useful, +dnl but WITHOUT ANY WARRANTY; without even the implied warranty of +dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +dnl GNU Affero General Public License for more details. +dnl +dnl You should have received a copy of the GNU Affero General Public License +dnl along with this program. If not, see . +dnl +dnl Karl O. Pinc +dnl +dnl +dnl m4 includes +include(`copyright.m4')dnl +include(`constants.m4')dnl +include(`tablemacros.m4')dnl +include(`grants.m4')dnl +dnl + +CREATE TABLE food_variations ( + key_column(`FOOD_VARIATIONS', `ID', INTEGER) + ,variant TEXT NOT NULL + emptytext_check(`Variant') + trimmedofspaces_check(`Variant') + ,LocalName TEXT NOT NULL + emptytext_check(`LocalName') + trimmedofspaces_check(`LocalName') +); + +grant_priv(`FOOD_VARIATIONS') diff --git a/db/schemas/lib/triggers/Makefile b/db/schemas/lib/triggers/Makefile index dffe2ff..56bbf85 100644 --- a/db/schemas/lib/triggers/Makefile +++ b/db/schemas/lib/triggers/Makefile @@ -59,7 +59,8 @@ ORDER := comm_ids \ aggression_event_log \ chimps_on_tikis \ tlk_brecord_notes_codes \ - community_membership_update_log + community_membership_update_log \ + food_variations DROP_EXISTING := true diff --git a/db/schemas/lib/triggers/create/food_variations.m4 b/db/schemas/lib/triggers/create/food_variations.m4 new file mode 100644 index 0000000..1cc9869 --- /dev/null +++ b/db/schemas/lib/triggers/create/food_variations.m4 @@ -0,0 +1,49 @@ +dnl Copyright (C) 2026 The Meme Factory, Inc. http://www.karlpinc.com/ +dnl +dnl This program is free software: you can redistribute it and/or modify it +dnl under the terms of the GNU Affero General Public License as published by +dnl the Free Software Foundation, either version 3 of the License, or +dnl (at your option) any later version. +dnl +dnl This program is distributed in the hope that it will be useful, +dnl but WITHOUT ANY WARRANTY; without even the implied warranty of +dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +dnl GNU Affero General Public License for more details. +dnl +dnl You should have received a copy of the GNU Affero General Public License +dnl along with this program. If not, see . +dnl +dnl Triggers for the food_variations table +dnl +dnl Karl O. Pinc + +dnl m4 includes +include(`copyright.m4')dnl +include(`constants.m4')dnl +include(`macros.m4')dnl + + +RAISE INFO 'food_variations_update_func'; +CREATE OR REPLACE FUNCTION food_variations_update_func () + RETURNS trigger + LANGUAGE plpgsql + sdb_function_set_search_path + AS $$ + BEGIN + -- Function for food_variations update trigger + -- + -- AGPL_notice(` --', `2026', + `The Meme Factory, Inc., www.karlpinc.com') + + cannot_change(`FOOD_VARIATIONS', `ID') + + RETURN NULL; + END; +$$; + + +RAISE INFO 'food_variations_update_trigger'; +CREATE TRIGGER food_variations_update_trigger + AFTER INSERT OR UPDATE + ON food_variations FOR EACH ROW + EXECUTE PROCEDURE food_variations_update_func(); diff --git a/db/schemas/lib/triggers/drop/food_variations.m4 b/db/schemas/lib/triggers/drop/food_variations.m4 new file mode 100644 index 0000000..f18db7f --- /dev/null +++ b/db/schemas/lib/triggers/drop/food_variations.m4 @@ -0,0 +1,23 @@ +dnl Copyright (C) 2026 The Meme Factory, Inc. http://www.karlpinc.com/ +dnl +dnl This program is free software: you can redistribute it and/or modify +dnl it under the terms of the GNU Affero General Public License as published by +dnl the Free Software Foundation, either version 3 of the License, or +dnl (at your option) any later version. +dnl +dnl This program is distributed in the hope that it will be useful, +dnl but WITHOUT ANY WARRANTY; without even the implied warranty of +dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +dnl GNU Affero General Public License for more details. +dnl +dnl You should have received a copy of the GNU Affero General Public License +dnl along with this program. If not, see . +dnl +dnl Drop triggers for tlk_brecord_notes_codes table +dnl +dnl Karl O. Pinc + +dnl m4 includes +include(`copyright.m4')dnl + +DROP FUNCTION IF EXISTS food_variations_update_func() CASCADE; diff --git a/doc/src/epilog.inc.m4 b/doc/src/epilog.inc.m4 index 2f8d49e..f429ef4 100644 --- a/doc/src/epilog.inc.m4 +++ b/doc/src/epilog.inc.m4 @@ -536,6 +536,14 @@ elo_ranks_daily_rst(sdb_male, MT)dnl .. |FOOD_PARTS.Part| replace:: :ref:`Part ` +.. |FOOD_VARIATIONS| replace:: :ref:`FOOD_VARIATIONS ` +.. |FOOD_VARIATIONS.ID| replace:: + :ref:`Part ` +.. |FOOD_VARIATIONS.Variant| replace:: + :ref:`Variant ` +.. |FOOD_VARIATIONS.LocalName| replace:: + :ref:`LocalName ` + .. |GROOM_SCANS_B| replace:: :ref:`GROOM_SCANS_B ` .. |GROOM_SCANS_B.EID| replace:: :ref:`EID ` diff --git a/doc/src/housekeeping.m4 b/doc/src/housekeeping.m4 index 2211453..6be47b6 100644 --- a/doc/src/housekeeping.m4 +++ b/doc/src/housekeeping.m4 @@ -36,5 +36,6 @@ The tables in this section are all in the ``housekeeping`` schema. housekeeping/aggression_event_log.rst housekeeping/biography_log.rst housekeeping/chimps_on_tikis.rst + housekeeping/food_variations.rst housekeeping/community_membership_update_log.rst housekeeping/tlk_brecord_notes_codes.rst diff --git a/doc/src/housekeeping/food_variations.m4 b/doc/src/housekeeping/food_variations.m4 new file mode 100644 index 0000000..e948d0b --- /dev/null +++ b/doc/src/housekeeping/food_variations.m4 @@ -0,0 +1,73 @@ +.. Copyright (C) 2026 The Meme Factory, Inc. www.karlpinc.com + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as + published by the Free Software Foundation, either version 3 of the + License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + +.. M4 setup +include(constants.m4)dnl +include(macros.m4)dnl +sdb_rst_quotes(`on')dnl +sdb_generated_rst()dnl + +.. _FOOD_VARIATIONS: + +FOOD_VARIATIONS +--------------- + +.. |FOOD_VARIATIONS_summary| replace:: + Each row records a food name variant. + +|FOOD_VARIATIONS_summary| + + +.. contents:: + :depth: 2 + + +.. _FOOD_VARIATIONS.ID: + +ID (IDentifier) +``````````````` + +.. |FOOD_VARIATIONS.ID_summary| replace:: |idcol| + +|FOOD_VARIATIONS.ID_summary| |notnull| + + +.. _FOOD_VARIATIONS.Variant: + +Variant +``````` + +.. |FOOD_VARIATIONS.Variant_summary| replace:: + The spelling of a variant name. + +|FOOD_VARIATIONS.Variant_summary| +|uniquenocase| + +|notonlyspaces| +|notnull| + + +.. _FOOD_VARIATIONS.LocalName: + +LocalName +````````` + +.. |FOOD_VARIATIONS.LocalName_summary| replace:: + The name of the food in the local venacular. + +|FOOD_VARIATIONS.LocalName_summary| + +|notonlyspaces| +|notnull| -- 2.34.1